/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entreprise;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import mapping.DBReservation;

/**
 *
 * @author Quoc-Khai
 */
public class ReservationService {
    public boolean createReservation(int reservationID, String patientName, String patientPhoneNumber, String patientEmail, Date reservationTime, String require) throws SQLException{
        DBReservation dbReservation = new DBReservation();
        Reservation iReservation = new Reservation();
        iReservation = dbReservation.getReservation(reservationID);
        if (iReservation.getReservationID().length() <= 0) {
            iReservation.setPatientName(patientName);
            iReservation.setPatientPhoneNumber(patientPhoneNumber);
            iReservation.setPatientEmail(patientEmail);
            iReservation.setReservationTime(reservationTime);
            iReservation.setRequire(require);
            
            dbReservation.createReservation(iReservation);
            return true;
        }        
        System.out.println("Reservation existe!");
        return false;
    }
    public boolean deleteReservation(int reservationID) throws SQLException{
        DBReservation dbReservation = new DBReservation();
        Reservation iReservation = new Reservation();
        iReservation = dbReservation.getReservation(reservationID);
        if (iReservation.getReservationID().length() > 0) {
            dbReservation.deleteReservation(reservationID);
            return true;
        }
        
        System.out.println("Reservation not existe!");
        return false;
    }
    public boolean updateReservation(int reservationID, String patientName, String patientPhoneNumber, String patientEmail, Date reservationTime, String require) throws SQLException{
        DBReservation dbReservation = new DBReservation();
        Reservation iReservation = new Reservation();
        iReservation = dbReservation.getReservation(reservationID);
        if (iReservation.getReservationID().length() > 0) {
            iReservation.setReservationID(String.valueOf(reservationID));
            iReservation.setPatientName(patientName);
            iReservation.setPatientPhoneNumber(patientPhoneNumber);
            iReservation.setPatientEmail(patientEmail);
            iReservation.setReservationTime(reservationTime);
            iReservation.setRequire(require);
            
            dbReservation.updateReservation(iReservation);
            return true;
        }
        
        System.out.println("Reservation not existe!");
        return false;
    }
    public List<Reservation> findReservations(String reservationName){
        List<Reservation> reservations=null;
        return reservations;
    }
}
